package com.controller;

import com.controller.vo.ResultVO;
import com.entity.User;
import com.service.UserInfoService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: AuthController
 * Description:
 *
 * @author L_Z_R
 * @version 1.0
 * @create 2025/05/29 11:28
 */
@RestController
@RequestMapping("/auth")
public class AuthController extends BaseController{
     @Autowired
     private UserInfoService  userInfoService;
     @GetMapping("/user")
     public ResultVO<User> getUser(HttpServletRequest request) {
          // 从请求上下文中获取用户ID
          String userId = (String) request.getAttribute("userId");
          // 根据用户ID查询用户信息
          User userInfo = userInfoService.selectUserInfoByAccountId(Integer.parseInt(userId));
          System.out.println("查询结果"+userInfo);
          return success(userInfo); // 返回用户信息
     }
}
